package dao;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;

import vo.StudyVo;

public class StudyDao {
	
	static StudyDao me;
	
	SqlSessionTemplate sqlSession;

	public SqlSessionTemplate getSqlSession() {
		return sqlSession;
	}

	public void setSqlSession(SqlSessionTemplate sqlSession) {
		this.sqlSession = sqlSession;
	}
	
	public StudyDao(){
		me=this;
	}
	
	
	public static StudyDao getDao() {
		return me;
	}
	
	public List<StudyVo> selectCategory(int menu_no){
		List<StudyVo> list = sqlSession.selectList("select_study_category", menu_no);
		return list;
	}
	
	public List<StudyVo> selectTitle(int cate_no){
		List<StudyVo> list = sqlSession.selectList("select_study_title", cate_no);
		return list;
	}
	public void insertStudy(StudyVo svo){
		sqlSession.insert("insert_study", svo);
	}
	public List<StudyVo> selectStudy(){
		List<StudyVo> list = sqlSession.selectList("select_study");
		return list;
	}
	
	public List<StudyVo> selectSubject(int title_no){
		List<StudyVo> list = sqlSession.selectList("select_study_subject",title_no);
		return list;
	}
	
	public String selectContent(String subject){
		String content = sqlSession.selectOne("select_study_content", subject);
		return content;
	}
	
	public List<StudyVo> selectCategoryAll(){
		List<StudyVo> list = sqlSession.selectList("select_study_category_all");
		return list;
	}
	
	public int selectStudyCount(){
		int count=sqlSession.selectOne("select_study_count");
		return count;
	}
	
	
	
	//ajax category---------------------------------------------------
	public int cateStep(int cate_no){
		int cate_step = sqlSession.selectOne("select_cate_step", cate_no);
		return cate_step;
	}
	
	public void categoryUp(int cate_no){
		sqlSession.update("update_category_up", cate_no);
	}
	public void categoryDown(int cate_no){
		sqlSession.update("update_category_down", cate_no);
	}
	public void stepUp(int cate_step){
		sqlSession.update("update_category_step_up", cate_step);
	}
	public void stepDown(int cate_step){
		sqlSession.update("update_category_step_down", cate_step);
	}
	public void deleteCategory(int cate_no){
		sqlSession.delete("delete_category", cate_no);
	}
	public void deleteCategoryTitle(int cate_no){
		sqlSession.delete("delete_category_title", cate_no);
	}
	public void deleteCategorySubject(int cate_no){
		sqlSession.delete("delete_category_subject", cate_no);
	}
	
	public void cateRename(StudyVo svo){
		sqlSession.update("cate_rename", svo);
	}
	//ajax category---------------------------------------------------
	
	//ajax title--------------------------------------------------------
	public int titleStep(int title_no){
		int title_step = sqlSession.selectOne("select_title_step", title_no);
		return title_step;
	}
	
	public void titleUp(int title_no){
		sqlSession.update("update_title_up", title_no);
	}
	public void titleDown(int title_no){
		sqlSession.update("update_title_down", title_no);
	}
	public void titleStepUp(int title_step){
		sqlSession.update("update_title_step_up", title_step);
	}
	public void titleStepDown(int title_step){
		sqlSession.update("update_title_step_down", title_step);
	}
	public void deleteTitle(int title_no){
		sqlSession.delete("delete_title_title", title_no);
	}
	public void deleteTitleSubject(int title_no){
		sqlSession.delete("delete_title_subject", title_no);
	}
	
	public void titleRename(StudyVo svo){
		sqlSession.update("title_rename", svo);
	}
	
	public int titleCateNo(int title_no){
		int cate_no = sqlSession.selectOne("select_title_one",title_no);
		return cate_no;
	}
	//ajax title--------------------------------------------------------
}
